package com.ymatou.iapi.godmch.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.dguser.parameter.UserCreateBean;
import com.ymatou.iapi.godmch.parameter.getProductPicAutoFillConfigBean;
import com.ymatou.iapi.godmch.parameter.setShareTypeBean;
import com.ymatou.iapi.godmch.service.getProductPicAutoFillConfigCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.DGUserCallService;
import com.ymttest.business.service.shenqi.GodmchManageCallService;
/**
*获取商户商品图片白边自动填充配置
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_getProductPicAutoFillConfig{
	private static getProductPicAutoFillConfigBean bean;
	private static getProductPicAutoFillConfigCall call;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("获取商户商品图片白边自动填充配置");
	}

	@Before
	public void caseUp() {
		bean=new getProductPicAutoFillConfigBean();
		call=new getProductPicAutoFillConfigCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(call.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getProductPicAutoFillConfig_001() {
		Logger.start(true,"获取商户商品图片白边自动填充配置--验证白边不自动填充配置");
		try {
			
			//渠道
			int userId_channl=GodmchManageCallService.CreateSellerMch();
			setShareTypeBean setShareTypeBean=GodmchManageCallService.initsetShareTypeV2(userId_channl);
			setShareTypeBean.setProductPicAutoFill(false);
			GodmchManageCallService.setShareTypeV2Call(setShareTypeBean);

			bean.setMchId(userId_channl);
			call.setData(bean);
			call.callService();			
			
			Logger.verifyEquals("200", call.getStatusCode1(), "验证status");
			Logger.verifyEquals(true, call.getMessage().contains("请求成功"), "验证msg");
			Logger.verifyEquals(false, call.getProductPicAutoFillEnabled(), "验证ProductPicAutoFillEnabled()");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getProductPicAutoFillConfig_002() {
		Logger.start(true,"获取商户商品图片白边自动填充配置--验证白边自动填充配置");
		try {
			//渠道
			int userId_channl=GodmchManageCallService.CreateSellerMch();
			setShareTypeBean setShareTypeBean=GodmchManageCallService.initsetShareTypeV2(userId_channl);
			setShareTypeBean.setProductPicAutoFill(true);
			GodmchManageCallService.setShareTypeV2Call(setShareTypeBean);

			bean.setMchId(userId_channl);
			call.setData(bean);
			call.callService();			
			
			Logger.verifyEquals("200", call.getStatusCode1(), "验证status");
			Logger.verifyEquals(true, call.getMessage().contains("请求成功"), "验证msg");
			Logger.verifyEquals(true, call.getProductPicAutoFillEnabled(), "验证ProductPicAutoFillEnabled()");			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getProductPicAutoFillConfig_003() {
		Logger.start(true,"获取商户商品图片白边自动填充配置--验证mch为空");
		try {

			//bean.setMchId(userId_channl);
			call.setData(bean);
			call.callService();			
			
			Logger.verifyEquals("4001", call.getStatusCode1(), "验证status");	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getProductPicAutoFillConfig_004() {
		Logger.start(true,"获取商户商品图片白边自动填充配置--验证mch不存在");
		try {

			bean.setMchId(121321231);
			call.setData(bean);
			call.callService();		
			
			Logger.verifyEquals("200", call.getStatusCode1(), "验证status");
			Logger.verifyEquals(false, call.getProductPicAutoFillEnabled(), "验证ProductPicAutoFillEnabled()");	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}